****************************************************
/*  Replication file for BJPS
Paper: When Reelection Increases Party Unity: Evidence from Parties in Mexico
Author: Lucia Motolinia*/
****************************************************

*******Replication Code for Speech Patterns*******

clear all
set more off
cd "C:\Users\luciam\Dropbox\NYU\Papers\Reelection and promises update\Manuscript_2\_REPLICATION_"
global path "C:\Users\luciam\Dropbox\NYU\Papers\Reelection and promises update\Manuscript_2\_REPLICATION_"


**Calculation of Euclidean Distance**
use "correspondance.dta", clear

bys reform state yearmonth partido: gen ld1m=d1 if jpc==1 | jpc==3
bys reform state yearmonth partido: gen ld2m=d2 if jpc==1 | jpc==3

bys reform state yearmonth partido: egen leaderd1m=mean(ld1m) 
bys reform state yearmonth partido: egen leaderd2m=mean(ld2m) 

gen distl1m=abs(d1-leaderd1m)
gen distl2m=abs(d2-leaderd2m)
gen distlm=sqrt(distl1m^2 + distl2m^2)
replace distl1m=. if distl1m==0
replace distl2m=. if distl2m==0
replace distlm=. if distlm==0

*standardized to normal
sum distlm
gen distlmn= (distlm-r(mean))/(r(sd))

sum distl1m
gen distl1mn= (distl1m-r(mean))/(r(sd))
sum distl2m
gen distl2mn= (distl2m-r(mean))/(r(sd))


**ANALYSIS**
use "correspondance.dta", clear

*Table 3 Columns (1)-(3)
local vars "distlmn distl1mn distl2mn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}

*Table 3 Columns (4)-(6)
local vars "distlmn distl1mn distl2mn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date i.pparty if jpc!=1, vce(bootstrap, cluster(edo) reps(15000) seed(12345)) a(edo)
}

*Table 4 (top panel: SSD vs PR)
local vars "distlmn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if ssd==1 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date if ssd==0 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}

*Table 4 (bottom panel: Plurality vs Non-plurality)
local vars "distlmn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if plu==1 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date if plu==0 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}

*Table 5 (top panel: Coalition vs Non-Coalition)
local vars "distlmn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if col==1 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date if col==0 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}

*Table 5 (bottom panel: Close Races vs Non-Close Races)
sum wmarg, d
gen wm=1 if wmarg<=0.025 & wmarg!=.
replace wm=0 if wm==. & wmarg!=.

local vars "distlmn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if wm==1 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date if wm==0 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}

*Figure 1 Bottom Panel (pre and post trends)
use "correspondance.dta", clear

forval i=1/9{
gen rm10`i'=0 if date<2015000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm10`i'=1 if date>=2015000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm10`i'=0 if date<2016000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm10`i'=1 if date>=2016000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm10`i'=0 if date<2013000`i' & (state=="Puebla")
replace rm10`i'=1 if date>=2013000`i' & (state=="Puebla")
replace rm10`i'=0 if date<2014000`i' & (state=="Nayarit")
replace rm10`i'=1 if date>=2014000`i' & (state=="Nayarit")
replace rm10`i'=. if reform==1
}

forval i=1/9{
gen rm20`i'=0 if date<2014000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm20`i'=1 if date>=2014000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm20`i'=0 if date<2015000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm20`i'=1 if date>=2015000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm20`i'=0 if date<2012000`i' & (state=="Puebla")
replace rm20`i'=1 if date>=2012000`i' & (state=="Puebla")
replace rm20`i'=0 if date<2013000`i' & (state=="Nayarit")
replace rm20`i'=1 if date>=2013000`i' & (state=="Nayarit")
replace rm20`i'=. if reform==1
}

forval i=10/12{
gen rm2`i'=0 if date<201400`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm2`i'=1 if date>=201400`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm2`i'=0 if date<201500`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm2`i'=1 if date>=201500`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm2`i'=0 if date<201200`i' & (state=="Puebla")
replace rm2`i'=1 if date>=201200`i' & (state=="Puebla")
replace rm2`i'=0 if date<201300`i' & (state=="Nayarit")
replace rm2`i'=1 if date>=201300`i' & (state=="Nayarit")
replace rm2`i'=. if reform==1
}

forval i=1/9{
gen rm30`i'=0 if date<2013000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm30`i'=1 if date>=2013000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm30`i'=0 if date<2014000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm30`i'=1 if date>=2014000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm30`i'=0 if date<2011000`i' & (state=="Puebla")
replace rm30`i'=1 if date>=2011000`i' & (state=="Puebla")
replace rm30`i'=0 if date<2012000`i' & (state=="Nayarit")
replace rm30`i'=1 if date>=2012000`i' & (state=="Nayarit")
replace rm30`i'=. if reform==1
}

forval i=10/12{
gen rm3`i'=0 if date<201300`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm3`i'=1 if date>=201300`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rm3`i'=0 if date<201400`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm3`i'=1 if date>=201400`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rm3`i'=0 if date<201100`i' & (state=="Puebla")
replace rm3`i'=1 if date>=201100`i' & (state=="Puebla")
replace rm3`i'=0 if date<201200`i' & (state=="Nayarit")
replace rm3`i'=1 if date>=201200`i' & (state=="Nayarit")
replace rm3`i'=. if reform==1
}

forval i=10/12{
gen rmp1`i'=0 if date<201500`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp1`i'=1 if date>=201500`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp1`i'=0 if date<201600`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp1`i'=1 if date>=201600`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp1`i'=0 if date<201300`i' & (state=="Puebla")
replace rmp1`i'=1 if date>=201300`i' & (state=="Puebla")
replace rmp1`i'=0 if date<201400`i' & (state=="Nayarit")
replace rmp1`i'=1 if date>=201400`i' & (state=="Nayarit")
}


forval i=1/9{
gen rmp20`i'=0 if date<2016000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp20`i'=1 if date>=2016000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp20`i'=0 if date<2017000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp20`i'=1 if date>=2017000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp20`i'=0 if date<2014000`i' & (state=="Puebla")
replace rmp20`i'=1 if date>=2014000`i' & (state=="Puebla")
replace rmp20`i'=0 if date<2015000`i' & (state=="Nayarit")
replace rmp20`i'=1 if date>=2015000`i' & (state=="Nayarit")
}

forval i=10/12{
gen rmp2`i'=0 if date<201600`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp2`i'=1 if date>=201600`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp2`i'=0 if date<201700`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp2`i'=1 if date>=201700`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp2`i'=0 if date<201400`i' & (state=="Puebla")
replace rmp2`i'=1 if date>=201400`i' & (state=="Puebla")
replace rmp2`i'=0 if date<201500`i' & (state=="Nayarit")
replace rmp2`i'=1 if date>=201500`i' & (state=="Nayarit")
}



forval i=1/9{
gen rmp30`i'=0 if date<2017000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp30`i'=1 if date>=2017000`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp30`i'=0 if date<2017000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp30`i'=1 if date>=2017000`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp30`i'=0 if date<2017000`i' & (state=="Puebla")
replace rmp30`i'=1 if date>=2017000`i' & (state=="Puebla")
replace rmp30`i'=0 if date<2016000`i' & (state=="Nayarit")
replace rmp30`i'=1 if date>=2016000`i' & (state=="Nayarit")
}

forval i=10/12{
gen rmp3`i'=0 if date<201700`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp3`i'=1 if date>=201700`i' & (state=="Jalisco" | state=="Queretaro" | state=="Campeche" | state=="CdMex" | state=="Chiapas" | state=="Colima" | state=="Guanajuato" | state=="Guerrero" | state=="Mexico" | state=="Tabasco" | state=="Sonora") 
replace rmp3`i'=0 if date<201700`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp3`i'=1 if date>=201700`i' & (state=="Oaxaca" | state=="Chihuahua" | state=="Durango" | state=="Tlaxcala" | state=="Veracruz" | state=="Sinaloa" | state=="Aguascalientes" | state=="Oaxaca" | state=="Hidalgo" | state=="Zacatecas") 
replace rmp3`i'=0 if date<201700`i' & (state=="Puebla")
replace rmp3`i'=1 if date>=201700`i' & (state=="Puebla")
replace rmp3`i'=0 if date<201600`i' & (state=="Nayarit")
replace rmp3`i'=1 if date>=201600`i' & (state=="Nayarit")
}

local vars "distlmn"
local treat "rmp110 rmp111 rmp112 rmp201 rmp202 rmp203 rmp204 rmp205 rmp206 rmp207 rmp208 rmp209 rmp210 rmp211 rmp212 rmp301 rmp302 rmp303 rmp304 rmp305 rmp306 rmp307 rmp308 rmp309 rmp310 rmp311 rmp312"
foreach x in `vars'{
foreach y in `treat'{
reg `x' c.treat#c.`y' i.edo i.date if jpc!=1, robust cluster(edo)
estimate store `x'_`y'
}
}

local vars "distlmn"
local treat "rm301 rm302 rm303 rm304 rm305 rm306 rm307 rm308 rm309 rm310 rm311 rm312 rm201 rm202 rm203 rm204 rm205 rm206 rm207 rm208 rm209 rm210 rm211 rm212 rm101 rm102 rm103 rm104 rm105 rm106 rm107 rm108 rm109"
foreach x in `vars'{
foreach y in `treat'{
reg `x' c.treat#c.`y' i.edo i.date if jpc!=1, robust cluster(edo)
estimate store `x'_`y'
}
}


coefplot (distlmn_rm301, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm302, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm303, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm304, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm305, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm306, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm307, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm308, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm309, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm310, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm311, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm312, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm201, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm202, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm203, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm204, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm205, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm206, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm207, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm208, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm209, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm210, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm211, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm212, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm101, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm102, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm103, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm104, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm105, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm106, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm107, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm108, mcolor(gs7) ciopts(color(gs7))) (distlmn_rm109, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp110, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp111, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp112, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp201, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp202, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp203, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp204, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp205, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp206, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp207, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp208, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp209, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp210, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp211, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp212, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp301, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp302, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp303, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp304, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp305, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp306, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp307, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp308, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp309, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp310, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp311, mcolor(gs7) ciopts(color(gs7))) (distlmn_rmp312, mcolor(gs7) ciopts(color(gs7))), vertical keep(c.treat#c.rm301 c.treat#c.rm302 c.treat#c.rm303 c.treat#c.rm304 c.treat#c.rm305 c.treat#c.rm306 c.treat#c.rm307 c.treat#c.rm308 c.treat#c.rm309 c.treat#c.rm310 c.treat#c.rm311 c.treat#c.rm312 c.treat#c.rm201 c.treat#c.rm202 c.treat#c.rm203 c.treat#c.rm204 c.treat#c.rm205 c.treat#c.rm206 c.treat#c.rm207 c.treat#c.rm208 c.treat#c.rm209 c.treat#c.rm210 c.treat#c.rm211 c.treat#c.rm212 c.treat#c.rm101 c.treat#c.rm102 c.treat#c.rm103 c.treat#c.rm104 c.treat#c.rm105 c.treat#c.rm106 c.treat#c.rm107 c.treat#c.rm108 c.treat#c.rm109 c.treat#c.rmp110 c.treat#c.rmp111 c.treat#c.rmp112 c.treat#c.rmp201 c.treat#c.rmp202 c.treat#c.rmp203 c.treat#c.rmp204 c.treat#c.rmp205 c.treat#c.rmp206 c.treat#c.rmp207 c.treat#c.rmp208 c.treat#c.rmp209 c.treat#c.rmp210 c.treat#c.rmp211 c.treat#c.rmp212 c.treat#c.rmp301 c.treat#c.rmp302 c.treat#c.rmp303 c.treat#c.rmp304 c.treat#c.rmp305 c.treat#c.rmp306 c.treat#c.rmp307 c.treat#c.rmp308 c.treat#c.rmp309 c.treat#c.rmp310 c.treat#c.rmp311 c.treat#c.rmp312) yline(0) xline(33.5) msymbol(S) legend(off) graphregion(col(white)) bgcol(white) name(p, replace)

**SUPPLEMENTARY APPENDIX**
*Table A1, A2 and A3 (validation T-tests)
ttest distlm if reform==0, by(ssd) /*A1*/

bys reform state date partido:  egen sdparty1= sd(d1)
bys reform state date partido:  egen sdparty2= sd(d2)

bys reform state date:  egen sdall1= sd(d1)
bys reform state date:  egen sdall2= sd(d2)

local parties "PRI PRD PAN PVEM PANAL MORENA"
foreach y in `parties'{
ttest sdparty1==sdall1 if partido=="`y'" /*A2*/
ttest sdparty2==sdall2 if partido=="`y'" 
}

bys reform state date: gen ld1pri=d1 if partido=="PRI" & (jpc==1 | jpc==3)
bys reform state date: gen ld2pri=d2 if partido=="PRI" & (jpc==1 | jpc==3)

bys reform state date: egen leaderprid1=mean(ld1pri) 
bys reform state date: egen leaderprid2=mean(ld2pri) 

gen distl1pri=abs(d1-leaderprid1)
gen distl2pri=abs(d2-leaderprid2)
gen distlpri=sqrt(distl1pri^2 + distl2pri^2)
replace distlpri=. if partido=="PRI"

ttest distlm==distlpri  /*A3*/

bys reform state date: gen ld1pan=d1 if partido=="PAN" & (jpc==1 | jpc==3)
bys reform state date: gen ld2pan=d2 if partido=="PAN" & (jpc==1 | jpc==3)

bys reform state date: egen leaderpand1=mean(ld1pan) 
bys reform state date: egen leaderpand2=mean(ld2pan) 

gen distl1pan=abs(d1-leaderpand1)
gen distl2pan=abs(d2-leaderpand2)
gen distlpan=sqrt(distl1pan^2 + distl2pan^2)
replace distlpan=. if partido=="PAN"

ttest distlm==distlpan /*A3*/

bys reform state date: gen ld1prd=d1 if partido=="PRD" & (jpc==1 | jpc==3)
bys reform state date: gen ld2prd=d2 if partido=="PRD" & (jpc==1 | jpc==3)

bys reform state date: egen leaderprdd1=mean(ld1prd) 
bys reform state date: egen leaderprdd2=mean(ld2prd) 

gen distl1prd=abs(d1-leaderprdd1) if distlm!=.
gen distl2prd=abs(d2-leaderprdd2) if distlm!=.
gen distlprd=sqrt(distl1prd^2 + distl2prd^2)
replace distlprd=. if partido=="PRD" 

ttest distlm==distlprd  /*A3*/

bys reform state date: gen ld1pvem=d1 if partido=="PVEM" & (jpc==1 | jpc==3)
bys reform state date: gen ld2pvem=d2 if partido=="PVEM" & (jpc==1 | jpc==3)

bys reform state date: egen leaderpvemd1=mean(ld1pvem) 
bys reform state date: egen leaderpvemd2=mean(ld2pvem) 

gen distl1pvem=abs(d1-leaderpvemd1)
gen distl2pvem=abs(d2-leaderpvemd2)
gen distlpvem=sqrt(distl1pvem^2 + distl2pvem^2)
replace distlpvem=. if partido=="PVEM"

ttest distlm==distlpvem /*A3*/


*Tables A4 and A5 (descriptive statistics)
sum distlm if jpc!=1

local varlist "distlm"
foreach x in `varlist'{
forval i=1/22{
display "`x' `i'"
sum distlm if edo==`i' & jpc!=1
return list
sca m1=r(mean)
matrix col1 =nullmat(col1) \ (m1)  
}
}
mat appolicy= col1
matlist appolicy


*Table A7 (distance to party centroid)
bys reform state yearmonth partido: gen sum_var1 = sum(d1)
bys reform state yearmonth partido: gen sum_var2 = sum(d2)

bys reform state yearmonth partido: gen count_var1 = sum(d1 < .)
bys reform state yearmonth partido: gen count_var2 = sum(d2 < .)

bys reform state yearmonth partido: gen mean_d1 = (sum_var1[_N] - d1) / (count_var1[_N] - 1)
bys reform state yearmonth partido: gen mean_d2 = (sum_var2[_N] - d2) / (count_var2[_N] - 1)

gen distx1=abs(d1-mean_d1)
gen distx2=abs(d2-mean_d2)
gen distx=sqrt(distx1^2 + distx2^2)
replace distx=. if distx==0

sum distx
gen distxn= (distx-r(mean))/(r(sd))

areg distxn c.treat#c.reform i.date, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)

*Table A8 (CA model estimated by state)
use "state_corr_mc.dta", clear
local vars "distlmstn distl1mstn distl2mstn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if state!="Sonora", vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date i.pparty2 if state!="Sonora", vce(bootstrap, cluster(edo) reps(15000) seed(12345)) a(edo)
}

*Table A9
use "correspondance.dta", clear
*inputing the leader from the month before
sort reform state partido date

gen leaderd1mi=leaderd1m
gen leaderd2mi=leaderd2m

by reform state partido: replace leaderd1mi=leaderd1mi[_n-1] if leaderd1m==.
by reform state partido: replace leaderd2mi=leaderd2mi[_n-1] if leaderd2m==.

gen distl1mi=abs(d1-leaderd1mi)
gen distl2mi=abs(d2-leaderd2mi)
gen distlmi=sqrt(distl1mi^2 + distl2mi^2)

replace distl1mi=. if distl1mi==0
replace distl2mi=. if distl2mi==0
replace distlmi=. if distlmi==0

sum distlmi
gen distlmin= (distlmi-r(mean))/(r(sd))

sum distl1mi
gen distl1min= (distl1mi-r(mean))/(r(sd))
sum distl2mi
gen distl2min= (distl2mi-r(mean))/(r(sd))

local vars "distlmin distl1min distl2min"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}
local vars "distlmin distl1min distl2min"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date i.pparty if jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}


*Table A8.1 (Chaisemartin and D'Haultfoeuille, 2020)
use "correspondance.dta", clear
did_multiplegt distlmn edo date did if jpc!=1, placebo(1) breps(1000) cluster(edo)

*Table A8.2 (Callaway and Sant'Anna, 2020)
use "correspondance.dta", clear
drop if jpc==1
gen gvar=0 if  treat==0
replace gvar=2015 if  treat==1 & leg_start_year==2015 | leg_start_year==2012
replace gvar=2016 if  treat==1 & leg_start_year==2016 | leg_start_year==2013

csdid distlmn treat, cluster(edo) time(year) gvar(gvar) agg(simple)
csdid distlmn treat, cluster(edo) time(year) gvar(gvar) agg(group)
csdid distlmn treat, cluster(edo) time(year) gvar(gvar) agg(calendar)


*Table A12 (Heterogeneous Effects: Governors Party vs Opposition)
use "correspondance.dta", clear
local vars "distlmn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if gov==1 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date if gov==0 & jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}

*Table A13 (Diff in means comparting legislator covariates)
use "legs_covariates.dta", clear
*(TOP: Diff in means, legislators from different cycles)
ttest education_years, by(reform) 
ttest polexperience_any_years, by(reform) 
ttest age, by(reform) 

*(BOTTOM: Diff in means, legislators in treatment and control)
ttest education_years, by(treat) 
ttest polexperience_any_years, by(treat) 
ttest age, by(treat) 


*Table A14 (RobustnessL Controlling for 2018 Gubernatorial Elections)
local vars "distlmn"
foreach x in `vars'{
areg `x' c.treat#c.reform c.calendar#c.reform i.date if jpc!=1, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}

*Table A15 (Decision to Speak)
use "speak.dta", clear
local vars "speak"
foreach x in `vars'{
areg `x' c.treat#c.reform i.month_year, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.month_year i.pparty, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}


*Table A16 (Party Leaders Moved Differentially)
use "correspondance.dta", clear
areg ld1m c.treat#c.reform i.date if (jpc==1 | jpc==3), vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg ld2m c.treat#c.reform i.date if (jpc==1 | jpc==3), vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg ld1m c.treat#c.reform i.date i.pparty if (jpc==1 | jpc==3), vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg ld2m c.treat#c.reform i.date i.pparty if (jpc==1 | jpc==3), vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)

*Table A16 (Parliamentary Group Size)
use "correspondance.dta", clear
quietly reg distlmn c.treat#c.reform i.edo i.date if jpc!=1, robust cluster(edo)
keep if e(sample)==1
bys reform state leg: gen ntime=_n
replace ntime=. if ntime!=1
bys reform state pparty: egen groupsize=sum(ntime)

bys reform state pparty: gen nsize=_n
replace nsize=. if nsize!=1

collapse (mean) groupsize treat reform edo date, by (yearmonth state pparty) 

areg groupsize c.treat#c.reform i.date, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)


*Table A16 (Heterogeneous Effects by Parliamentary Group Size)
use "correspondance.dta", clear
quietly reg distlmn c.treat#c.reform i.edo i.date if jpc!=1, robust cluster(edo)
keep if e(sample)==1
bys reform state leg: gen ntime=_n
replace ntime=. if ntime!=1
bys reform state pparty: egen groupsize=sum(ntime)

bys reform state pparty: gen nsize=_n
replace nsize=. if nsize!=1

local vars "distlmn"
foreach x in `vars'{
areg `x' c.treat#c.reform i.date if jpc!=1 & groupsize<=5, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date if jpc!=1 & groupsize>5 & groupsize<15, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
areg `x' c.treat#c.reform i.date if jpc!=1 & groupsize>15, vce(bootstrap, cluster(edo) reps(3050) seed(12345)) a(edo)
}
